<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p:dialog xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	modal="true" width="650" height="350" resizable="false" 
	widgetVar="dialogAddEstado" id="dialogEstado" closable="false"
	appendToBody="true">

	<link type="text/css" rel="stylesheet" href="../../resources/css/style.css" />
	
	<f:facet name="header">
		<h:outputText value="Cadastrar Estado" />
	</f:facet>
	
	<h:form id="formAddEstado" prependId="false">
		<p:messages id="messageFormEstado"/>
		
		<h:panelGrid columns="1" style="padding:5px;">
			<h:outputText value="Código" />
			<p:inputText style="width:100px; opacity:1;" disabled="true" value="#{ordemServicoBean.newEstado.id}"/>
		</h:panelGrid>
		
		<h:panelGrid columns="2" style="padding:5px;">
			<h:outputText value="Estado *" />
			<h:outputText value="Sigla" />
			
			<p:inputText style="width:210px;" value="#{ordemServicoBean.newEstado.estado}" required="true" requiredMessage="Informe o estado." maxlength="30"/>
			<p:inputText style="width:100px;" value="#{ordemServicoBean.newEstado.sigla}" maxlength="2"/>
		</h:panelGrid>
		
		<h:panelGrid columns="4" style="padding:5px;" id="panelEstadoPais">
			<h:outputText value="Pais *" />
			<h:outputText value="Sigla" />
			<h:outputText value="DDI" />	
			<h:outputText value="" />		
			
			<p:autoComplete id="inputPaisPais" var="pais" value="#{ordemServicoBean.newEstado.pais}" maxlength="30"
				itemLabel="#{pais.pais}" itemValue="#{pais}" size="50" required="true" requiredMessage="Selecione o país."
				converter="paisConverter" completeMethod="#{ordemServicoBean.getPaisByQuery}">
				<p:ajax event="itemSelect" process="@this inputPaisPais" update="inputPaisSigla inputPaisDdi"/>
			</p:autoComplete>
			
			<p:inputText style="width:100px;opacity:1;" disabled="true" value="#{ordemServicoBean.newEstado.pais.sigla}" id="inputPaisSigla"/>
			<p:inputText style="width:100px;opacity:1;" disabled="true" value="#{ordemServicoBean.newEstado.pais.ddi}" id="inputPaisDdi"/>
			<p:commandButton icon="ui-icon-search" style="height:24px;" actionListener="#{ordemServicoBean.openDialogListPais}" process="@this" title="Selecionar país"/>
		</h:panelGrid>
		
		<h:panelGrid columns="1" style="padding:5px;">
			<h:outputText value="* Campos obrigatórios" />
		</h:panelGrid>
		
		<div id="popup-buttons" style="padding-top: 10px; text-align: right;">
			<p:commandButton value="Salvar" style="height:28px;" actionListener="#{ordemServicoBean.saveEstadoFromDialog}" update="@this, messageFormEstado" icon="ui-icon-disk"/>
			<p:commandButton value="Cancelar" style="height:28px;" actionListener="#{ordemServicoBean.closeDialogAddEstado}" immediate="true" icon="ui-icon-cancel"/>
		</div>
	</h:form>
</p:dialog>